<!DOCTYPE html>
<html lang="en"
    xmlns:f="http://java.sun.com/jsf/core"
    xmlns:h="http://java.sun.com/jsf/html"
    xmlns:ui="http://java.sun.com/jsf/facelets" 
>
    <h:body>
    	<ui:composition template="../Template/template.xhtml">
    		<ui:define name="content">
    			<f:metadata>
    				<f:event type="preRenderView" listener="#{MessagesBean.fillMessagesLists}"/>
				</f:metadata>
    			<section id="content">
	    			<h2> Mes messages </h2>
	    			<p> Consultez vos messages </p>
	    			<div class="tab">
        				<ul>
            				<li>
            					<a href="#tabs-1">Boite de réception</a>
            				</li>
            				<li>
            					<a href="#tabs-2">Messages envoyés</a>
            				</li>
            				<li>
            					<a href="#tabs-3">Messages supprimés</a>
            				</li>
        				</ul>
        				<div id="tabs-1" style="margin:10px;">
        					<h:dataTable rendered="#{!empty MessagesBean.receivedMessagesList}" value="#{MessagesBean.receivedMessagesList}" var="p" class="datatable">
								<h:column style="width:30px;">
									<f:facet name="header">Date</f:facet>
									<h:outputText value="#{p.msgDate}" />
								</h:column>
								<h:column>
									<f:facet name="header">A Utilisateur</f:facet>
									<h:outputText value="#{p.receiver.usrFirstname} #{p.receiver.usrLastname}" />
								</h:column>
								<h:column>
									<f:facet name="header">De Utilisateur</f:facet>
									<h:outputText value="#{p.sender.usrFirstname} #{p.sender.usrLastname}" />
								</h:column>
								<h:column>
									<f:facet name="header">Sujet</f:facet>
									<h:outputText value="#{p.msgSubject}" />
								</h:column>
								<h:column>
									<f:facet name="header">Projet</f:facet>
									<h:outputText value="#{p.project.prjLabel}" />
								</h:column>
								<h:column>
									<f:facet name="header">Actions</f:facet>
									<h:form>
										<h:commandLink value="Supprimer" action="#{MessagesBean.deleteMessage}" styleClass="btn small">
											<f:param name="msgId" id="msg" value="#{p.msgId}"></f:param>
											<f:param name="tabN" id="tabN" value="1"></f:param>
										</h:commandLink>
										<h:link outcome="DetailsMessage" value="Voir le détail" styleClass="btn small">
											<f:param name="msgid" id="msgid" value="#{p.msgId}" />
										</h:link>
									</h:form>
								</h:column>
							</h:dataTable>
							<h:panelGroup rendered="#{empty MessagesBean.receivedMessagesList}">
								<p>
									<h5 style='text-align:center;'> Aucun éléments dans la boite de réception </h5>
								</p>
							</h:panelGroup>
        				</div>
        				<div id="tabs-2" style="margin:10px;">
        					<h:dataTable rendered="#{!empty MessagesBean.sentMessagesList}" value="#{MessagesBean.sentMessagesList}" var="p" class="datatable">
								<h:column>
									<f:facet name="header">Date</f:facet>
									<h:outputText value="#{p.msgDate}" />
								</h:column>
								<h:column>
									<f:facet name="header">A Utilisateur</f:facet>
									<h:outputText value="#{p.receiver.usrFirstname} #{p.receiver.usrLastname}" />
								</h:column>
								<h:column>
									<f:facet name="header">De Utilisateur</f:facet>
									<h:outputText value="#{p.sender.usrFirstname} #{p.sender.usrLastname}" />
								</h:column>
								<h:column>
									<f:facet name="header">Sujet</f:facet>
									<h:outputText value="#{p.msgSubject}" />
								</h:column>
								<h:column>
									<f:facet name="header">Projet</f:facet>
									<h:outputText value="#{p.project.prjLabel}" />
								</h:column>
								<h:column>
									<f:facet name="header">Actions</f:facet>
									<h:form>
										<h:commandLink value="Supprimer" action="#{MessagesBean.deleteMessage}" styleClass="btn small">
											<f:param name="msgId" id="msg" value="#{p.msgId}"></f:param>
											<f:param name="tabN" id="tabN" value="2"></f:param>
										</h:commandLink>
										<h:link outcome="DetailsMessage" value="Voir le détail" styleClass="btn small">
											<f:param name="msgid" id="msgid" value="#{p.msgId}" />
										</h:link>
									</h:form>
								</h:column>
							</h:dataTable>
							<h:panelGroup rendered="#{empty MessagesBean.sentMessagesList}">
								<p>
									<h5 style='text-align:center;'> Aucun éléments dans les messages envoyés </h5>
								</p>
							</h:panelGroup>
        				</div>
        				<div id="tabs-3" style="margin:10px;">
        					<h:dataTable rendered="#{!empty MessagesBean.deletedMessagesList}" value="#{MessagesBean.deletedMessagesList}" var="p" class="datatable">
								<h:column>
									<f:facet name="header">Date</f:facet>
									<h:outputText value="#{p.msgDate}" />
								</h:column>
								<h:column>
									<f:facet name="header">A Utilisateur</f:facet>
									<h:outputText value="#{p.receiver.usrFirstname} #{p.receiver.usrLastname}" />
								</h:column>
								<h:column>
									<f:facet name="header">De Utilisateur</f:facet>
									<h:outputText value="#{p.sender.usrFirstname} #{p.sender.usrLastname}" />
								</h:column>
								<h:column>
									<f:facet name="header">Sujet</f:facet>
									<h:outputText value="#{p.msgSubject}" />
								</h:column>
								<h:column>
									<f:facet name="header">Projet</f:facet>
									<h:outputText value="#{p.project.prjLabel}" />
								</h:column>
								<h:column>
									<f:facet name="header">Actions</f:facet>
									<h:form>
										<h:commandLink value="Supprimer" action="#{MessagesBean.deleteMessage}" styleClass="btn small">
											<f:param name="msgId" id="msg" value="#{p.msgId}"></f:param>
											<f:param name="tabN" id="tabN" value="3"></f:param>
										</h:commandLink>
										<h:link outcome="DetailsMessage" value="Voir le détail" styleClass="btn small">
											<f:param name="msgid" id="msgid" value="#{p.msgId}" />
										</h:link>
									</h:form>
								</h:column>
							</h:dataTable>
							<h:panelGroup rendered="#{empty MessagesBean.deletedMessagesList}">
								<p>
									<h5 style='text-align:center;'> Aucun éléments dans les messages supprimés </h5>
								</p>
							</h:panelGroup>
        				</div>
        			</div>
				</section>
    		</ui:define>
    	</ui:composition>    	
    </h:body>
 
</html>